package com.tbit.main.controller;

import com.tbit.common.entity.view.Result;
import com.tbit.main.util.DateTimeUtil;
import com.tbit.manager.api.MachineOAApi;
import com.tbit.manager.api.dto.MachineOperationsStatDTO;
import com.tbit.manager.api.dto.MachineStatReturnDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/operationsAnalysis/machine")
public class MachineOAController {

    @Autowired
    private MachineOAApi machineOAApi;


    /**
     * 获取产生订单的车辆数据
     * @author: mo.shanyong
     * @date: 2025/3/4 16:36
     * @param: accountId 区域id
     * @param: startDate 开始时间
     * @param: endDate 结束时间
     * @return: com.tbit.uqbike.object.view.JsonResult
     */
    @GetMapping("/getOrderCarLine")
    public Result<List<MachineStatReturnDTO>> getOrderCarLine(Integer accountId, String startDate, String endDate) {
        List<MachineStatReturnDTO> orderCarLineData = machineOAApi.getOrderCarLineData(accountId, startDate,endDate);
        return Result.success(orderCarLineData);
    }

    /**
     * 按照短、中、长获取车辆闲置折线图数据
     * @author: mo.shanyong
     * @date: 2025/3/4 16:41
     * @param: accountId 区域id
     * @param: startDate 开始时间
     * @param: endDate 结束时间
     * @return: com.tbit.uqbike.object.view.JsonResult
     */
    @GetMapping("/getIdleCarLine")
    public Result<List<MachineOperationsStatDTO>> getIdleCarLine(Integer accountId, String startDate, String endDate) {
        List<MachineOperationsStatDTO> idleCarLineData = machineOAApi.getIdleCarLineData(accountId, startDate, endDate);
        return Result.success(idleCarLineData);
    }

    /**
     * 获取计费车辆分布折线图数据
     * @author: mo.shanyong
     * @date: 2025/3/4 17:09
     * @param: accountId 区域id
     * @param: startDate 日期：2025-03-01
     * @param: endDate 日期：2025-03-01
     * @return: com.tbit.uqbike.object.view.JsonResult
     */
    @GetMapping("/getChargingCarLine")
    public Result<List<MachineStatReturnDTO>> getChargingCarLine(Integer accountId, String startDate, String endDate) {
        List<MachineStatReturnDTO> chargingCarLineData = machineOAApi.getChargingCarLineData(accountId, startDate, endDate);
        return Result.success(chargingCarLineData);
    }

    /**
     * 低电占比折线图
     * @author: mo.shanyong
     * @date: 2025/3/4 17:12
     * @param: accountId 区域id
     * @param: startDate 时间
     * @param: endDate 时间
     * @return: com.tbit.uqbike.object.view.JsonResult
     */
    @GetMapping("/getBatteryLine")
    public Result<List<MachineStatReturnDTO>> getBatteryLine(Integer accountId, String startDate, String endDate) {
        log.info("accountId:{},startDate:{},endDate:{}", accountId, startDate,endDate);
        List<MachineStatReturnDTO> batteryLineData = machineOAApi.getBatteryLineData(accountId, startDate, endDate);
        return Result.success(batteryLineData);
    }
}
